package com.rimi.service.impl;

import com.rimi.bean.Doctor;
import com.rimi.commons.CommonResult;
import com.rimi.commons.ResultStatus;
import com.rimi.mapper.DoctorMapper;
import com.rimi.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liHaiYang
 * @version V1.0
 * @Description: (用一句话描述该文件做什么)
 * @date 2021/7/7 14:56
 */
@Service
public class DoctorServiceImpl implements DoctorService {

    @Autowired
    DoctorMapper doctorMapper;

    @Override
    public CommonResult addDoctor(Doctor doctor) {
        int row = doctorMapper.addDoctor(doctor);
        return row == 1? CommonResult.onSuccess(null):CommonResult.onFailed(ResultStatus.ADD_FAILED);
    }

    @Override
    public List<Doctor> showDoctor() {
        return doctorMapper.showDoctor();
    }

    @Override
    public CommonResult deleteDoctorByDoctorId(Integer doctorId) {
        int row = doctorMapper.deleteDoctorByDoctorId(doctorId);
        return row == 1?CommonResult.onSuccess(null):CommonResult.onFailed(ResultStatus.DELETE_FAILED);
    }

    @Override
    public CommonResult updateDoctor(Doctor doctor) {
        int row = doctorMapper.updateDoctor(doctor);
        return row == 1? CommonResult.onSuccess(null):CommonResult.onFailed(ResultStatus.UPDATE_FAILED);
    }


}
